<script type="text/javascript">
    function bitformatter(val, row){
        if(val != null){
            if (val == 1 || val == '1') {
                return '<span class="label label-success arrowed">Active</span>';
            } else {
                return '<span class="label label-important arrowed-in">Deactive</span>';
            }
        } else {
            return val;
        }
    }

    function gender_formatter(val, row){
        if(val != null){
            if (val == 1 || val == '1') {
                return '<span class="badge badge-warning">Mr.</span>';
            } else {
                return '<span class="badge badge-success">Ms.</span>';
            }
        } else {
            return val;
        }
    }

    function is_active_formatter(val, row){
        if(val != null){
            if (val == 1 || val == '1') {
                return '<span class="label label-success arrowed">On</span>';
            } else {
                return '<span class="label label-important arrowed-in">Off</span>';
            }
        } else {
            return val;
        }
    }

    function yes_no_formatter(val, row){
        if(val != null){
            if (val == 1 || val == '1') {
                return '<span class="label label-success arrowed">Yes</span>';
            } else {
                return '<span class="label label-important arrowed-in">No</span>';
            }
        } else {
            return val;
        }
    }

    function dateformatter(val, row){
        if(val != null){
            var d = new Date(val);
            var date = val.split(' ')[0];
            var time = val.split(' ')[1];
            return date.split('-')[0] + '/' + date.split('-')[1] + '/' + date.split('-')[2] + time.split(':')[0] + "h:" + time.split(':')[1] + "p";
        } else {
            return val;
        }
    }

    function imgformatter(val, row){
        if(val != null){
            return "<img height='100'"
                +" src='<?php echo $this->baseUrl()?>/public/uploads/images/" + val
                +"' class='gridimg'/>";
        } else {
            return val;
        }
    }

    function emailformatter(val, row){
        if(val != null || val != ''){
            return '<a href="mailto:'+ val +'" style="">' + val + '</a>';
        } else {
            return val;
        }
    }

    function linkformatter(val, row){
        if(val != null){
            var tmpLink = val;
            if(tmpLink.length >= 60){
                tmpLink.substr(0, 57);
                tmpLink = tmpLink + "...";
            }
            return '<a href="' + val + '" target="_blank">' + tmpLink + '</a>';
        } else {
            return val;
        }
    }
</script>